package com.konglz.publisher.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Description
 * @Author konglz
 * @Data 2023/5/13 13:03
 */
@RestController
@RequestMapping("/topic")
@Api(tags = "发布订阅-话题模式")
public class TopicMessageController {
    @Autowired
    private RabbitTemplate rabbitTemplate;

    /**
     * @Description: top案例
     * @return: void
     * @Author: konglz
     * @Date: 2023/5/13
     */
    @GetMapping("/{message}")
    @ApiOperation("测试简单消息队列")
    public void topic(@PathVariable String message){
        String exchangeName = "konglz.topic";
        //user.# topicQueue1能收到模块正在更新
        //rabbitTemplate.convertAndSend(exchangeName,"user.admin", message);
        //#.log topicQueue2收到模块正在更新
        //rabbitTemplate.convertAndSend(exchangeName,"log", message);
        //user.#、#.log topicQueue1、topicQueue2收到模块正在更新
        rabbitTemplate.convertAndSend(exchangeName,"user.log", message);
    }
}
